package leetcode.秋招.字节跳动.后端第二批2018;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/7/10 14:50
 * @description：https://www.nowcoder.com/test/question/66b68750cf63406ca1db25d4ad6febbf?pid=8537209&tid=45447906
 */
public class 用户喜好 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        HashMap<Integer, Integer>[] maps = new HashMap[n + 1];
        maps[0] = new HashMap<Integer, Integer>();
        for (int i = 1; i <= n; i++) {
            HashMap<Integer, Integer> map = new HashMap(maps[i - 1]);
            int num = in.nextInt();
            map.put(num, map.getOrDefault(num, 0) + 1);
            maps[i] = map;
        }
        int q = in.nextInt();
        for (int i = 0; i < q; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            int k = in.nextInt();
            HashMap<Integer, Integer> lMap = maps[l - 1];
            HashMap<Integer, Integer> rMap = maps[r];
            System.out.println(rMap.getOrDefault(k, 0) - lMap.getOrDefault(k, 0));
        }
    }
}


